//
//  main.cpp
//  LinkListWithoutHeaderNodeDemo
//
//  Created by 李禹 on 15/5/31.
//  Copyright (c) 2015年 dayu. All rights reserved.
//

#include <iostream>
#include "LinkListWithoutHeaderNode.h"
#include "CommonFunction.h"

int main(int argc, const char * argv[]) {

    LinkList L;
    InitList(L);
    ListInsert(L, 1, 56);
    ListInsert(L, 2, 63);
    ListInsert(L, 3, 98);
    ListInsert(L, 1, 22);
    ListTraverse(L, print1);
    ReveserList(L);
    ListTraverse(L, print1);
    ElemType e;
    ListDelete(L, 2, e);
    printf("%d\n", e);
    ListTraverse(L, print1);
    ReveserList(L);
    ListTraverse(L, print1);
    ListInsert(L, 4, 5);
    ListTraverse(L, print1);
    ListTraverse(L, print1);
    int idx = 4;
    GetElem(L, idx, e);
    printf("第%d个数 = %d\n", idx, e);
    e = 4;
    printf("%d 在第%d个位置\n", e, LocationElem(L, e, equal));
    ElemType cur_e = 54;
    Status exit = ProiorElem(L, cur_e, e);
    if (exit) {
        printf("%d的前驱元素为 %d\n", cur_e, e);
    }else {
        printf("%d的没有前驱元素\n", cur_e);
    }
    cur_e = 22;
    exit = NextElem(L, cur_e, e);
    if (exit) {
        printf("%d的后继元素为 %d\n", cur_e, e);
    }else {
        printf("%d的没有后继元素\n", cur_e);
    }
    ListTraverse(L, print1);
    ReveserList(L);
    ListTraverse(L, print1);
    ClearList(L);
//    DestroyList(L);
    printf("是否为空?%d", ListEmpty(L));
    return 0;
}
